<script src="{{ getAssets }}js/amazeui.datatables.min.js?v={{ assets_version }}"></script>
<script>
	var tables = $('#dataTables').DataTable({
		"sAjaxSource" : "{{ urlfor "AllocationController.Warehousing"}}"
		,"bLengthChange": false
		,"fnServerData" : function(sSource, aoData, fnCallback) {
			var params = checkQueryTableData(aoData)
			$('#search_key').val() ? params.filter = $('#search_key').val() : '';
			$('#fromdep').val() ? params.FromDep = $('#fromdep').val() : '';
			$('#todep').val() ? params.ToDep = $('#todep').val() : '';
			
			$.post(sSource, JSON.stringify(params),function(resp) {
				fnCallback(resp);
			},'json')
		}
		,columns: [
			{"data" : "Number", "bSortable": false}
			,{"bSortable": false,render:function(data, type, full, meta) {
				  return full.FromDepName;
			}}
            ,{"bSortable": false,render:function(data, type, full, meta) {
                  return full.ToDepName;
            }}
			,{"data" : "OperatorName", "bSortable": false}
			,{"data" : "ProductNumber", "bSortable": false}
			,{"data" : "Auditing", "bSortable": false,render:function(data, type, full, meta) {
				if(data == 1) {
					return '<span class="am-badge am-badge-warning">待处理</span>';
				}else if(data == 2) {
					return '<span class="am-badge am-badge-success">待审核</span>';
				}else if(data == 3) {
					return '<span class="am-badge am-badge-primary">退回</span>';
				}else if(data == 4) {
                    return '<span class="am-badge am-badge-secondary">确认调拨</span>';
                }else if(data == 5) {
                    return '<span class="am-badge am-badge-warning">等待接收</span>';
                }else if(data == 6) {
                    return '<span class="am-badge am-badge-secondary">接收完成</span>';
                }
			}}
			,{"data" : "CreatedAt", "bSortable": false, render:function(data, type, full, meta) {
				return timetransDate(data);	
			}}
			 ,{   
				"mDataProp": "Action", 
				"bSortable": false, 
				"sWidth":"10%",
				"render": function ( data, type, full, meta ) { 
					var btns = '';
                    btns += '<a class="am-btn am-btn-success am-btn-xs" href="/allocation/warehousing/view/'+ full.Id +'">详情</a>';
					return btns;  
				}
			 } 
		]
		,"aLengthMenu":[20, 50, 100, 200]
		,'bLengthChange': true
		,"serverSide": true
		,"bPaginate" : true
		,"bFilter" : false	//是否启动过滤、搜索功能 
		,"bInfo" : true //是否显示页脚信息，DataTables插件左下角显示记录数
		,"bProcessing" : true //DataTables载入数据时，是否显示‘进度’提示  
		  
	});
	
	$("#searchsubmit").bind("click", function () { //点击按钮 触发table重新请求服务器
		$("#dataTables").dataTable().fnDraw(false);
	});
</script>